<?php

class Zend_View_Helper_Image extends Zend_View_Helper_Abstract {
	
	public function image($file, $width, $height, $mode = false, $path = 'media/') {
		$path = $this->view->baseUrl . '/' . $path;
		$image = $path . 'image/' . $width . '/' . $height . ($mode ? '/' : '') . $mode . '/';
		
		preg_match('/\.(jpe?g|gif|png)$/i', $file, $matches);
		if (count($matches) && file_exists($this->view->basePath . '/media/' . $file))
			$image .= $file;
		else
			$image .= 'no_image.png';
		
		return $image;
	}
}